package org.boot.wxipad.support.api.impl;

import lombok.RequiredArgsConstructor;
import org.boot.wxipad.common.error.WxIpadErrorException;
import org.boot.wxipad.support.bean.friend.WxIpadAddFriendResp;
import org.boot.wxipad.support.constant.WxIpadApiPathConstants;
import org.boot.wxipad.support.api.WxIpadFriendService;
import org.boot.wxipad.support.api.WxIpadService;
import org.boot.wxipad.support.bean.friend.WxIpadAddFriendReq;


/**
 * @author liyuncong
 * @version 1.0
 * @file WxIpadFriendServiceImpl
 * @brief WxIpadFriendServiceImpl
 * @details WxIpadFriendServiceImpl
 * @date 2024-08-05
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2024-08-05               liyuncong          Created
 */

@RequiredArgsConstructor
public class WxIpadFriendServiceImpl implements WxIpadFriendService {
    private final WxIpadService mainService;

    @Override
    public WxIpadAddFriendResp addFriend(WxIpadAddFriendReq addFriendReq) throws WxIpadErrorException {
        String apiUrl = this.mainService.getWxIpadConfigStorage().getApiUrl(WxIpadApiPathConstants.Friend.ADD_FRIENDS);
        String response = this.mainService.postForm(apiUrl, addFriendReq.toJson());
        return WxIpadAddFriendResp.fromJson(response);
    }
}
